package com.qch.concurrent.demo_05_interrupt;

/**
 * @Author qch
 * @Date 2021/7/29
 * thread.isInterrupted()与Thread.interrupted()的区别
 */
public class MyThread3 extends Thread {
    @Override
    public void run() {
        int i=0;
        while (true) {
            //中断状态
            boolean interrupted = isInterrupted();
            System.out.println("中断标记" + interrupted);
            ++i;
            if (i>200)
            {
                boolean interrupted1 = Thread.interrupted();
                System.out.println("重置中断状态：" + interrupted1);
                interrupted1 = Thread.interrupted();
                System.out.println("重置中断状态：" + interrupted1);
                interrupted = isInterrupted();
                System.out.println("中断标记：" + interrupted);
                break;
//                boolean interrupted1 = Thread.interrupted();
//                System.out.println("重置中断状态"+interrupted1);
//                interrupted1 = Thread.interrupted();
//                System.out.println("重置中断状态"+interrupted1);
//                interrupted= interrupted();
//                System.out.println("中断标记"+interrupted);
//                break;
            }
        }
    }
}
